#ifndef DBSESSION_H
#define DBSESSION_H
#include "User.h"
#include "Weight.h"
#include "DietPlan.h"
#include "FitnessPlan.h"
#include <qsqldatabase.h>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QSharedPointer>



class DbSession
{

private:
    QSqlDatabase db;
    QSharedPointer<User> us;
              //  QSharedPointer<QVector<QSharedPointer<User> > > users;

public:
                static DbSession& getInstance();
                DbSession();
              //  ~dbsession();

                /*Function login return user's id if user exist else reyurn 0*/
                int login(QString login1, QString password1);

                QSharedPointer<User> getUser(int id);

                int getUserIdByToken(QString token);

                QSharedPointer<QVector<QSharedPointer<Weight> > > getWeights(int id);

                QSharedPointer<QVector<QSharedPointer<User> > > getAllUsers();

                QSharedPointer<QVector<QSharedPointer<DietPlan> > > getDietPlan(int userId);

                QSharedPointer<QVector<QSharedPointer<FitnessPlan> > > getFitnessPlan(int userId);

                bool isFreeLogin(QString login1);

                bool registerUser(QString login1, QString password1);

                void addWeight(int userId, double weight);

                bool isExistWeight(int userId);

                void addDietPlan(int userId, QString dietplan);

                void editDietPlan(int dietPlanId, QString dietplan);

                bool isExistDietPlan(int userId);

                void addFitnessPlan(int userId, QString fitnessplan);

                void editFitnessPlan(int fitnessPlanId, QString fitnessplan);

                bool isExistFitnessPlan(int userId);

                QSharedPointer<QVector<QSharedPointer<DietComment> > > getDietComments(int dietId);

                QSharedPointer<QVector<QSharedPointer<FitnessComment> > > getFitnessComments(int fitnessId);

                void addDietComment(int DietPlanId, int userId, QString info);

                void addFitnessComment(int FitnessPlanId, int userId, QString info);

                void sortTableAsc(QString nameTable);



};

#endif // DBSESSION_H
